#/bin/python
#coding:utf8
'''
Created on 2011-4-29

@author: mars
'''

import web
import config
from controller import index


    
urls = ('/upload/?', 'controller.uploader.userlogoUpload', \
        '/captcha/?','controller.utilities.Captcha',\
            
        '/?', 'controller.index.initIndex', \
        
        '/login/?', 'controller.user.loginuser', \
        '/register/?', 'controller.user.register', \
        '/logout/?', 'controller.user.logout', \
        '/account/?','controller.user.UserInfo',\
        '/account/editpasswd/?','controller.user.modifyPassword',\
        '/account/changelogo/?','controller.user.changeLogo',\
        '/emailCheck/?', 'controller.user.emailAvail', \
        
        '/userhome/(\d*)/?', 'controller.user.userhome', \
        '/userhome/(\d*)/myproblem/?','controller.user.MySponserProblem',\
        '/userhome/(\d*)/myfocus/?','controller.user.MyFocusProblem',\
        
        '/problem/create/?', 'controller.problem.createProblem', \
        '/problem/(\d*)/?','controller.problem.probleminfo',\
        '/problem/(\d*)/answer/?', 'controller.answer.answerProblem',\
        '/problem/(\d*)/modify/?','controller.problem.modifyProblem',\
        '/problem/(\d*)/addComment/?','controller.problem.addComment',\
        '/type/(\d*)/?', 'controller.problem.problemsByType',\
        
        '/checkAnswer/?','controller.answer.checkAnswer',\
        
        '/captcha/?','controller.utilities.Captcha')

application = web.application(urls, globals())

session = web.session.Session(application, web.session.DiskStore(config.session_path), \
                              initializer={'current_user':None})

def session_hook():
    web.ctx.session = session
    
application.add_processor(web.loadhook(session_hook))

index.get_index_data().start()

if __name__ == "__main__":
    application.run()    
